<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Request;

class Base extends Controller
{
    public function _initialize()
    {
        $cate = Db::name('cate')
            ->order('id asc')
            ->select();
        $this->assign('cate',$cate);

        $tags = Db::name('tags')
            ->order('id asc')
            ->select();
        $this->assign('tags',$tags);

        $request  = Request::instance();
        // 获取当前域名
        $site_url = $request->domain();
        $site_url = $site_url.'/index.php/index/search/index?keywords=';
        $this->assign('site_url',$site_url);

        $system   = Db::name('system')
            ->where(array('id'=>1))
            ->find();
        $this->assign('system',$system);

        $this->right();
    }

    public function right(){
        // 点击排行
        $click_right = Db::name('article')
            ->order('click desc')
            ->limit(9)
            ->select();
        $this->assign('click_right',$click_right);
            
        // 推荐
        $recommend = Db::name('article')
            ->where(array('state'=>1))
            ->order('click desc')
            ->limit(8)
            ->select();
        $this->assign('recommend',$recommend);
    }
}
